<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>onmousedown</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .bord{
            border: 1px dashed #ee2602;
            width: 90%;
            margin: 20px auto;
        }
        .title{
            font-size: 20px;
            font-weight: bold;
            margin: 20px;
        }
        .introduce{
            font-size: 16px;
            margin: 0 0 20px 50px;
        }
        .red{
            color: red;
        }
    </style>
    <script>
        function myFunction(elmnt,clr){
            elmnt.style.color=clr;
        }
    </script>
</head>
<body>
<div class="bord">
    <div class="title">onmousedown</div>
    <div class="introduce">
        onmousedown 事件会在鼠标按键被按下时发生。
    </div>
</div>
<div class="bord">
    <div class="title">演示效果</div>
    <p>点击以下文字不松开，文字变红色。松开之后变绿色。</p><br/>
    <p onmousedown="myFunction(this,'red')" onmouseup="myFunction(this,'green')">
        点击点击点击
    </p>
</div>
<div class="bord">
    <div class="title">代码</div>
    <div class="introduce">
        <pre>
            &lt;script&gt;
        function myFunction(elmnt,clr){
            elmnt.style.color=clr;
        }
            &lt;/script&gt;

            &lt;p&gt;点击以下文字不松开，文字变红色。松开之后变绿色。&lt;/p&gt;
    &lt;p onmousedown="myFunction(this,'red')" onmouseup="myFunction(this,'green')"&gt;
        点击点击点击
    &lt;/p&gt;
        </pre>
    </div>
</div>
</body>
</html>